package push.tools.service.service.egova;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import push.tools.service.constant.ApiUrl;
import push.tools.service.entity.CaseBean;

@Service
public class PreDataService {
    private static final Logger logger = LoggerFactory.getLogger(PreDataService.class);

    public CaseBean handle(CaseBean caseBean) {
        if (caseBean.eventcode == null) {
            caseBean.eventcode = "";
        }
        if (caseBean.eventDesc == null) {
            caseBean.eventDesc = "";
        }
        if (caseBean.status == null) {
            caseBean.status = "";
        }
        if (caseBean.eventClass == null) {
            caseBean.eventClass = "";
        }
        if (caseBean.eventTime == null) {
            caseBean.eventTime = "";
        }
        if (caseBean.locationDesc == null) {
            caseBean.locationDesc = "";
        }
        if (caseBean.currentStepName == null) {
            caseBean.currentStepName = "";
        }
        if (caseBean.currentDeptName == null) {
            caseBean.currentDeptName = "";
        }
        if (caseBean.currentDealPeopleName == null) {
            caseBean.currentDealPeopleName = "";
        }
        if (caseBean.fileUrls == null) {
            caseBean.fileUrls = "";
        }
        if (caseBean.fileUrls.contains("125.89.138.49")) {
            String fileUrls = caseBean.fileUrls;
            caseBean.fileUrls = fileUrls.replaceAll("https://125.89.138.49:7888", ApiUrl.baseHost);
        }
        //案件号前面加id
        caseBean.eventcode = "YD" + caseBean.eventcode;
        //日期格式化
        caseBean.eventTime = caseBean.eventTime.replaceAll("T", " ");
        return caseBean;
    }
}
